package cn.siat.gene.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.siat.common.security.utils.SecurityUtils;
import cn.siat.gene.domain.ModelInfo;
import cn.siat.gene.mapper.ModelInfoMapper;
import cn.siat.gene.service.IModelInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.StringUtils;

/**
 * @Description: 模型信息
 * @Author: Administrator
 * @Date:   2022-10-22
 * @Version: V1.0
 */
@Service
public class ModelInfoServiceImpl extends ServiceImpl<ModelInfoMapper, ModelInfo> implements IModelInfoService {
    @Autowired
    private ModelInfoMapper modelInfoMapper;
    @Override
    public Boolean checkNumber(String number, String modelName, String id) {
        QueryWrapper<ModelInfo> wrapper = new QueryWrapper<ModelInfo>().eq("is_delete",1);
        //校验编码
        if(StringUtils.hasLength(number)){
            wrapper.eq("number", number);
        }
        //校验名称
        if(StringUtils.hasLength(modelName)){
            wrapper.eq("model_name", modelName);
        }
        //编辑弹窗不校验本身
        if(id != null){
            wrapper.ne("id", id);
        }
        Long count = modelInfoMapper.selectCount(wrapper);
        if(count == null || count == 0L){
            return  false;
        }
        return true;
    }
    @Override
    public int checkDelFlagById(String id) {
        return modelInfoMapper.checkDelFlagById(id);
    }
}
